'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE ,UUID,TEXT,FLOAT} = app.Sequelize;
  var moment = require('moment');

  const fd_address = app.model.define('fd_address', {
    id: { type: UUID, primaryKey: true},
    user_id:STRING(50),//用户id
    realname:STRING(10),//姓名，
    is_default:{type:STRING(1),defaultValue:'0'},//是否是默认地址，1是，0 否
    phone:STRING(50),//电话
    province:STRING(255),//省市区
    address:STRING(255),//详细地址
    deleted:{type:STRING(1),defaultValue:'0'} ,//0:可用 ,1:不可用
    created_at: {
      type: DATE,
      get() {
        return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
      }
    },
    updated_at: {
      type: DATE,
      get() {
        return moment(this.getDataValue('updated_at')).format('YYYY-MM-DD HH:mm:ss');
      }
    }
  },{freezeTableName: true,timestamps: true})

  return fd_address;
};
